<?php
class ColumnModel extends CategoryModel {
	
	//根据ID获取导航的组
	public function getCateTreeById($id = 0, $activeUrls = array()){
		if($id > 0){
			$cateTree = $this->getCateTree(array(), $activeUrls);
			
			foreach($cateTree as $val){
				if($val['id'] == $id){
					return $val;
				}
			}
		}else{
			return false;	
		}
	}
	
	public function getAllCate(){
		$cateList = $this->getAll(array('status'=>1), 'row_sort ASC, id ASC');
		foreach($cateList as $key=>$val){
			//处理导航url
			if(isset($val['column_type'])){
				switch($val['column_type']){
					case 'About':
					case 'Join':
						$cateList[$key]['url'] = setViewUrl($val['column_type'],array('id'=>$val['column_value']));
					break;
					case 'NewsCate':
					case 'GoodsCate':
						$cateList[$key]['url'] = setCateUrl($val['column_type'],array('id'=>$val['column_value']));
					break;
					case 'DiyUrl':
						$cateList[$key]['url'] = $val['column_value'];
					break;
				}
			}else{
				$cateList[$key]['url'] = setCateUrl($this->name,$val);	
			}
		}
		return $cateList;
	}
}